﻿using System;
/********************************************************************************
** project   ： #PROJECTNAME#
** date      ： #CREATIONDATE#
** auth      ： #AUTHORNAME#
** desc      ： 
**
** Version   ： #VERSION#
*********************************************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Node：
/// </summary>
public class Node : IComparable<Node>
{

    public bool _canWalk;
    public Vector3 _worldPos;
    public int _gridX, _gridY;
    public int gCost;
    public int hCost;
    public int fCost
    {
        get
        {
            return gCost + hCost;
        }
    }
    public Node parent;
    /// <summary>
    /// 记录自己是否在open列表 为了优化
    /// </summary>
    public bool IsOpen;
    /// <summary>
    /// 记录自己是否在关闭类表 为了优化
    /// </summary>
    public bool IsClose;
    public Node(bool CanWalk,Vector3 Position,int x,int y)
    {
        this._canWalk = CanWalk;
        _worldPos = Position;
        _gridX = x;
        _gridY = y;
    }
    /// <summary>
    /// 比较函数
    /// </summary>
    /// <param name="other"></param>
    /// <returns></returns>
    public int CompareTo(Node other)
    {
        int ret = 0;
        if (fCost < other.fCost)
        {
            ret = -1;
        }
        else if (fCost > other.fCost)
        {
            ret = 1;
        }
        return ret;
    }
}